package com.ruoyi.restaurant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.restaurant.vo.DashboardVo;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.restaurant.domain.SysJiagong;
import com.ruoyi.restaurant.service.ISysJiagongService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 后厨加工情况Controller
 * 
 * @author ruoyi
 * @date 2022-05-07
 */
@RestController
@RequestMapping("/jiagong/show")
public class SysJiagongController extends BaseController
{
    @Autowired
    private ISysJiagongService sysJiagongService;

    /**
     * 查询后厨加工情况列表
     */
    @PreAuthorize("@ss.hasPermi('jiagong:show:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysJiagong sysJiagong)
    {
        startPage();
        List<SysJiagong> list = sysJiagongService.selectSysJiagongList(sysJiagong);
        return getDataTable(list);
    }

    /**
     * 导出后厨加工情况列表
     */
    @PreAuthorize("@ss.hasPermi('jiagong:show:export')")
    @Log(title = "后厨加工情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysJiagong sysJiagong)
    {
        List<SysJiagong> list = sysJiagongService.selectSysJiagongList(sysJiagong);
        ExcelUtil<SysJiagong> util = new ExcelUtil<SysJiagong>(SysJiagong.class);
        util.exportExcel(response, list, "后厨加工情况数据");
    }

    /**
     * 获取后厨加工情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('jiagong:show:query')")
    @GetMapping(value = "/{makeId}")
    public AjaxResult getInfo(@PathVariable("makeId") Integer makeId)
    {
        return AjaxResult.success(sysJiagongService.selectSysJiagongByMakeId(makeId));
    }

    /**
     * 新增后厨加工情况
     */
    @PreAuthorize("@ss.hasPermi('jiagong:show:add')")
    @Log(title = "后厨加工情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysJiagong sysJiagong)
    {
        return toAjax(sysJiagongService.insertSysJiagong(sysJiagong));
    }

    /**
     * 修改后厨加工情况
     */
    @PreAuthorize("@ss.hasPermi('jiagong:show:edit')")
    @Log(title = "后厨加工情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysJiagong sysJiagong)
    {
        return toAjax(sysJiagongService.updateSysJiagong(sysJiagong));
    }

    /**
     * 删除后厨加工情况
     */
    @PreAuthorize("@ss.hasPermi('jiagong:show:remove')")
    @Log(title = "后厨加工情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{makeIds}")
    public AjaxResult remove(@PathVariable Integer[] makeIds)
    {
        return toAjax(sysJiagongService.deleteSysJiagongByMakeIds(makeIds));
    }

    /**
     * Echarts饼状图数据接口
     * @return
     */
    @GetMapping("/testchartsv2")
    public ResponseEntity<List<DashboardVo>> testchartsv2(){
        return ResponseEntity.ok(this.sysJiagongService.countByCategoryNames());
    }
}
